# include "VertexBufferBindAble.h"
# include "d3d11.h"

VertexBufferBindAble::VertexBufferBindAble(ID3D11Device* _device, const Vertex* _vertices, size_t _vertex_size)
{
	D3D11_BUFFER_DESC bd = {};
	bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	bd.ByteWidth = _vertex_size;
	bd.StructureByteStride = sizeof(Vertex);
	D3D11_SUBRESOURCE_DATA sd = {};
	sd.pSysMem = _vertices;
	_device->CreateBuffer(&bd, &sd, this->m_buffer.GetAddressOf());
}

void VertexBufferBindAble::bind(ID3D11DeviceContext* _context)
{
	_context->IASetVertexBuffers(0, 1, this->m_buffer.GetAddressOf(), &this->m_stride, &this->m_offset);
}

VertexBufferBindAble::~VertexBufferBindAble()
{

}
